-
Notifications
You must be signed in to change notification settings - Fork 2
feat(dom): DOM - toHaveFocus #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
const error = new AssertionError({ | ||
actual: this.actual, | ||
expected: document.activeElement, | ||
message: "Expected the element to have focus.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about the messaging to be:
"Expected the element to be focused" ?
const invertedError = new AssertionError({ | ||
actual: this.actual, | ||
expected: document.activeElement, | ||
message: "Expected the element not to have focus.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also in here, what do you think about the messaging to be:
"Expected the element NOT to be focused" ?
const input1 = getByTestId("input1"); | ||
const input2 = getByTestId("input2"); | ||
input1.focus(); | ||
const test = new ElementAssertion(input2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion.
If you dont add .focus()
, any element is focused so, I think the test could be easier like
const input1 = getByTestId("input1"); | |
const input2 = getByTestId("input2"); | |
input1.focus(); | |
const test = new ElementAssertion(input2); | |
const input1 = getByTestId("input1"); | |
const test = new ElementAssertion(input1); |
Added the toHaveFocus matcher with its tests.